package com.cmf.myproject.service.system.user.dto;

import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;

import com.system.core.view.layui.table.TableViewReqDto;

@Data
@EqualsAndHashCode(callSuper = true)
public class BossUserQueryFilter extends TableViewReqDto{

	//
	private Date createTime;
	//
	private Long id;
	//是否锁定
	private Boolean isLocked;
	//昵称/备注名
	private String nick;
	//密码
	private String password;
	//电话号码
	private String phone;
	//
	private Date updateTime;
	//用户名
	private String userName;
	//外键-用户权限关系ID
	private Long userRoleId;
	/**
	 * 
	 * jdbctype:timestamp
	 */
	private String createTimeStrStart;
	private String createTimeStrEnd;
	
	/**
	 * 
	 * jdbctype:timestamp
	 */
	private String updateTimeStrStart;
	private String updateTimeStrEnd;
	

	public String toQueryString() {
		StringBuilder param = new StringBuilder();
		/**
		 * jdbcType:timestamp
		 */
		if(StringUtils.isNotBlank(getCreateTimeStrStart())) {
			param.append("&createTimeStrStart=");
			param.append(getCreateTimeStrStart());
		}
		if(StringUtils.isNotBlank(getCreateTimeStrEnd())) {
			param.append("&createTimeStrEnd=");
			param.append(getCreateTimeStrEnd());
		}
		/**
		 * jdbcType:bigint(20)
		 */
		if(getId() != null) {
			param.append("&id=");
			param.append(getId());
		}
		/**
		 * jdbcType:tinyint(1)
		 */
		if(getIsLocked() != null) {
			param.append("&isLocked=");
			param.append(getIsLocked());
		}
		/**
		 * 昵称/备注名
		 * jdbcType:varchar(20)
		 */
		if(StringUtils.isNotBlank(getNick())) {
			param.append("&nick=");
			param.append(getNick());
		}
		/**
		 * 密码
		 * jdbcType:varchar(100)
		 */
		if(StringUtils.isNotBlank(getPassword())) {
			param.append("&password=");
			param.append(getPassword());
		}
		/**
		 * 电话号码
		 * jdbcType:varchar(20)
		 */
		if(StringUtils.isNotBlank(getPhone())) {
			param.append("&phone=");
			param.append(getPhone());
		}
		/**
		 * jdbcType:timestamp
		 */
		if(StringUtils.isNotBlank(getUpdateTimeStrStart())) {
			param.append("&updateTimeStrStart=");
			param.append(getUpdateTimeStrStart());
		}
		if(StringUtils.isNotBlank(getUpdateTimeStrEnd())) {
			param.append("&updateTimeStrEnd=");
			param.append(getUpdateTimeStrEnd());
		}
		/**
		 * 用户名
		 * jdbcType:varchar(20)
		 */
		if(StringUtils.isNotBlank(getUserName())) {
			param.append("&userName=");
			param.append(getUserName());
		}
		/**
		 * jdbcType:bigint(20)
		 */
		if(getUserRoleId() != null) {
			param.append("&userRoleId=");
			param.append(getUserRoleId());
		}
//		if(param.length() > 0)
//			return "?"+param.toString().substring(1, param.length());
//		else
		return param.toString();
	}
	
	@Override
	public String toString() {
		return toQueryString();
	}
}
